home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17550 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  62 lines

  1. Path: bcarh8ab.bnr.ca!jcobban
  2. From: jcobban@bnr.ca (Jim Cobban)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Deriving class from IOSTREAMs
  5. Date: 16 Apr 1996 13:39:00 GMT
  6. Organization: Bell-Northern Research Canada
  7. Message-ID: <4l07tk$djq@bcarh8ab.bnr.ca>
  8. References: <4ku9qa$7mt@bcarh8ab.bnr.ca> <3172F862.7053@braunschweig.netsurf.de>
  9. Reply-To: jcobban@nortel.ca (Jim Cobban)
  10. NNTP-Posting-Host: bcarsf1f.bnr.ca
  11.  
  12.  
  13. In article <3172F862.7053@braunschweig.netsurf.de>,
  14. Dieter Lⁿcking  <luecking@braunschweig.netsurf.de> wrote:
  15. >Jim Cobban wrote:
  16. >> 
  17. >> I am trying to define a class which has the following characteristics:
  18. >> 
  19. >>   1) It supports the insertion (<<) operator of the ostream class.
  20. >>   2) Output is organized into units of work.  No part of a unit of work
  21. >>      can be written to the output device until the unit of work is complete.
  22. >>      Then all of the text in the unit of work must be placed on the same line
  23. >>      of output.  In other words if there is enough room on the current line
  24. >>      to hold all of the text then it will be printed on the current line,
  25. >>      otherwise a new line is started and the text is written on the new line.
  26. >>   3) When a new line is started, including the very first line in the output,
  27. >>      an application specified prefix is written before the first unit of
  28. >>      work.
  29. >> 
  30. >> The first requirement dictates that my class be derived directly or
  31. >> indirectly from ostream.  
  32. >
  33. >[1]     No - this is wrong - you may use "ostream& operator << (ostream&, const aclass&);"
  34. >
  35. You have misunderstood.  I do not want to be able to insert an instance of my
  36. class into an ostream.  I want my class to support all of the insertions
  37. which are part of the ostream class.  So my class has to be on the left hand
  38. side of the insertion operator.
  39.  
  40. Or possibly I have misunderstood your point.
  41.  
  42. >> The second requirement seems to me to dictate that
  43. >> my class be derived, in particular, from ostrstream, which provides a buffer
  44. >> in which output can be held until a unit of work is complete.  I would like
  45. >> the end of a unit of work to be signalled by a manipulator, but I have had a
  46. >> great deal of difficulty in getting that to work.
  47. >> [...] 
  48. >
  49. >[2,3]     It is possible to use "ostream& operator << (ostream&, const aclass&);", too.
  50. >
  51. >Bye Dieter.
  52. >
  53. >
  54.  
  55.  
  56. -- 
  57. Jim Cobban   |  jcobban@nortel.ca                   |  Phone: (613) 763-8013
  58. Nortel (MCS) |                                      |  FAX:   (613) 763-5199
  59. |                                                                             |
  60. |   The opinions expressed are those of the author and do not necessarily     |
  61. |   represent the opinions of Nortel.                                         |
  62.